package com.oceansoft.mobile.weixin.service;

import com.oceansoft.mobile.biz.admin.entity.Merchant;
import com.oceansoft.mobile.common.base.entity.Pager;
import com.oceansoft.mobile.common.base.entity.Query;
import com.oceansoft.mobile.weixin.entity.WX_Reply;
import com.oceansoft.mobile.weixin.entity.WX_User;
import com.oceansoft.mobile.weixin.entity.WX_User_sub;
import com.oceansoft.mobile.weixin.entity.message.req.SuperMessage;
import com.oceansoft.mobile.weixin.entity.message.resp.Article;

import java.util.List;
import java.util.Map;

public interface WechatService {

	/**
	 *
	 *
	 * @return
     */
	String getSTAccessToken(String merid)throws Exception;

	/***
	 * 根据公众号access_token获得JsapiTicket
	 * @return
     */
	String getJsapiTicket();

	/**
	 * 根据公众号access_token获得JsapiTicket（不存入缓存）
	 * @return
     */
	String getJsapiTicket2();

	public String getAccessTokenByopenId(String openid);



	public String findWXOpenIdbyMerId(String mer_id);

	/**
	 * 根据商家Id查询所有一级菜单
	 */
	List<Map<String,Object>> findFirstMenu(String openid);
	/**
	 * 根据商家Id查询相对应的二级菜单
	 */
	List<Map<String,Object>> findSecondMenu(Long first_menu_id);

	 /**
     * 根据微信公众账号原始id查询商家
     *
     * @param weixin_openid 微信公众账号原始id
     */
    public Merchant findbyOpenid(String weixin_openid);

    /**
     * 保存用户向公众号发送的消息
     * @param sm
     * @return
     */
    public boolean saveUserMsg(SuperMessage sm);

    /**
     * 记录用户关注/取消信息
     * @param sub
     * @return
     */
    public boolean saveUserSub(WX_User_sub sub);



    public WX_Reply queryReplySub(String wx_openid);


    public WX_Reply queryReplyKey(String wx_openid,String key);


    /**
     * 查询智能回复的内容
     * @param reply
     * @return
     */
    public String queryReplyMaterialText(WX_Reply reply);

    public List<Article> queryReplyMaterialArticel(WX_Reply reply);

    public WX_User subscribeWXUser(String user_openid,String wx_openid);
    public void addWXUser(String user_openid, String wx_openid);

    public WX_User getWXUser(String user_openid,String wx_openid);
    /**
     *
     * @param user_openid
     * @return
     */
    public WX_User getWXUser(String user_openid);
    /**
     * 加载微信接收到的信息
     * @param toUserName
     * @param query
     * @return
     */
    public Pager<SuperMessage> loadNewsByPage(String toUserName, Query query) throws Exception ;
    /**
     * 加载三天之前的信息
     * @param toUserName
     * @param query
     * @return
     * @throws Exception
     */
    public Pager<SuperMessage> loadNewsByPage3(String toUserName, Query query,Integer dateType) throws Exception;

}
